<div class="container">
		            <div class="row">
		                <div class="col-md-12">
		                    <div class="titlepage">
		                        <h2>商品详情</h2>
		                    </div>
		                </div>
		            </div>
		        </div>
		        <div class="brand-bg">
		            <div class="container">
						<div class="item-shop-title">
								<div class="item-shop-name">
									<p class="hidden-val"></p>
									<p class="isname">店铺名加载中...</p>
									<a id="loadshop" href="javascript:void(0);">进入店铺</a>
								</div>

								<div class="item-shop-title-img">
									<img src="icon/Product-Sale-Flyer-Template-V-3-990x518.jpg"/>
								</div>
						</div>
						<div class="row">
							<div class="item-bg">
								<form>
									<div class="item-img brand_color">
										<img  src="images/about.png" alt="img" />
									</div>
									<div class="item-words">
										<div class="item-words1">
											<p class="hidden-val"></p>
											<h3>商品名称有这么长的</h3>
											<p class="desc">这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这就是商品描述这</p>
										</div>
										<p>商品规格:</p>
										<div class="item-guige-list">
											<div>
												<input type="radio" name="size"/>加长的
											</div>
										</div>
										<div class="item-button">
											<a id="addincart" class="btn btn-warning">加入购物车</a>
											<p class="singleprice">单价: <span>0.00</span></p>
										</div>
									</div>
								</form>
							</div>
						</div>
		            </div>
		        </div>
<script type="text/javascript">
	$(function (){
		doGetItem();
		$("#loadshop").click(function (){
			let shopId = $(".item-shop-name .hidden-val").text();
			let url=`/ruoyi/user-shop/${shopId}`;
			$("#mainContentId").data("shopId",shopId);
			jumphtml(url);
		});
		$("#addincart").click(function (){
			let radio = $(".item-guige-list").find(`input[type=radio]:checked`);
			if (radio.length<=0){
				alert("请选择规格");
				return ;
			}
			let itemId = $(".item-words1 .hidden-val").text();
			let sizeId = radio.parents().data("size").sizeId;
			let url = `/ruoyi/item/addcart`;
			let params = {"itemId":itemId,"sizeId":sizeId};
			$.ajax({
				url:url,
				type:"post",
				data: params,
				dataType:"json",
				success(result) {
					if (result.status===200){
						alert("加入成功!");
					}
				},
				error() {
					alert("加入失败!");
				}
			});


		});
	});
	function doGetItem(){
		let itemId = $("#mainContentId").data("itemId");
		let url = `/ruoyi/item/getitem`;
		$.ajax({
			url:url,
			data:{"itemId":itemId},
			success(result){
				if (result.status===200){
					doLoadItem(result.data);
				}
			},
			error(){
				alert("加载失败!");
			}
		});

	}
	function doLoadItem(item){
		$(".item-words1 .hidden-val").text(item.itemId);
		$(".item-words1 h3").text(item.title);
		$(".item-words1 .desc").text(item.itemDesc);
		$(".item-shop-name .hidden-val").text(item.shopId);
		$(".item-shop-name .isname").text(item.shopName);
		$(".item-shop-title-img").empty();
		$(".item-shop-title-img").append(`<img src="${item.logo}"/>`);
		$(".item-img").empty();
		$(".item-img").append(`<img src="${item.image}"/>`)
		$(".singleprice span").text(item.price);
		doGetSizes(item.sizes);
	}
	function doGetSizes(sizes){
		let sizeList = $(".item-guige-list");
		sizeList.empty();
		for (let i in sizes){
			let sizediv = $("<div></div>");
			sizediv.data("size",sizes[i]);
			sizediv.append(`<input type="radio" name="size"/>${sizes[i].sizeName}`);
			sizeList.append(sizediv);
		}

	}
</script>